import path from "node:path";
import express from "express";
import cookieParser from "cookie-parser";
import config from "../config/config.js";
import Loger from "./log4.js";
import Firewall from "./firewall.js";
import CoreMiddleware from "./corsMiddle.js";

const router = express.Router();

let corsMiddle = new CoreMiddleware(config.whitelistIps);
let loger = new Loger(path.join(process.cwd(), config.logPath));
let firewall = new Firewall(config.whiteReferers);

router.use(corsMiddle.middleware());
router.use(express.json());
router.use(express.urlencoded({ extended: true }));
router.use(cookieParser());
router.use(loger.middleware());
router.use(firewall.middleware());

export default router;
